//package com.source.code.analyzer;
//
//import com.github.javaparser.JavaParser;
//import com.github.javaparser.ParseResult;
//import com.github.javaparser.ast.CompilationUnit;
//import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
//import com.source.code.extractor.ChildMethodExtractor;
//import com.source.code.extractor.MethodInfoExtractor;
//import com.source.code.extractor.impl.child.ChildMethodSelfExtractor;
//import com.source.code.extractor.impl.info.ClassMethodInfoExtractor;
//import com.source.code.extractor.impl.inner.ClassMethodInnerExtractor;
//import com.source.code.extractor.impl.info.InterfaceMethodInfoExtractor;
//import com.source.code.extractor.impl.inner.InterfaceMethodInnerExtractor;
//import com.source.code.model.MethodInfo;
//import com.source.code.model.MethodInfoStatic;
//import java.io.FileInputStream;
//import java.io.IOException;
//import java.util.List;
//import java.util.Optional;
//
///**
// * 类信息分析器
// *
// * @author wangchangjie
// * @date 2024/02/01
// */
//public class ClassInfoAnalyzer {
//
//
//    /**
//     * 分析
//     *
//     * @param filePath  文件路径
//     * @param className 类名
//     * @return {@link List}<{@link MethodInfo}>
//     */
//    public Optional<List<MethodInfoStatic>> analyze(String filePath, String className) {
//        try (FileInputStream fileInputStream = new FileInputStream(filePath)) {
//            JavaParser parser = new JavaParser();
//            ParseResult<CompilationUnit> parse = parser.parse(fileInputStream);
//            CompilationUnit compilationUnit = parse.getResult().orElseThrow(() -> new RuntimeException("Parsing error"));
//
//            Optional<ClassOrInterfaceDeclaration> interfaceByName = compilationUnit.getInterfaceByName(
//                className);
//            Optional<ClassOrInterfaceDeclaration> classByName = compilationUnit.getClassByName(
//                className);
//
//            if (interfaceByName.isPresent()) {
//                // 是接口
//                InterfaceMethodInnerExtractor interfaceMethodInnerExtractor = new InterfaceMethodInnerExtractor();
//                MethodInfoExtractor methodInfoExtractor = new InterfaceMethodInfoExtractor(interfaceMethodInnerExtractor);
//                ClassOrInterfaceDeclaration interfaceDeclaration = interfaceByName.get();
//                List<MethodInfoStatic> methodInfos = methodInfoExtractor.extractMethodInfo(interfaceDeclaration, compilationUnit);
//                return Optional.of(methodInfos);
//            }else if (classByName.isPresent()){
//                // 是类
//                ChildMethodExtractor childMethodExtractor = new ChildMethodSelfExtractor();
//                ClassMethodInnerExtractor classMethodInnerExtractor = new ClassMethodInnerExtractor(childMethodExtractor);
//                MethodInfoExtractor methodInfoExtractor = new ClassMethodInfoExtractor(classMethodInnerExtractor);
//                ClassOrInterfaceDeclaration classDeclaration = classByName.get();
//                List<MethodInfoStatic> methodInfos = methodInfoExtractor.extractMethodInfo(classDeclaration, compilationUnit);
//                return Optional.of(methodInfos);
//            }
//        } catch (IOException e) {
//            e.printStackTrace();
//            return Optional.empty();
//        }
//        return Optional.empty();
//    }
//}